package com.atom.module.lib.opengles

import com.atom.module.lib.opengles.geometry.Matrix4
import com.atom.module.lib.opengles.geometry.Plane
import com.atom.module.lib.opengles.geometry.Vec3
import org.junit.Assert
import org.junit.Test

class PlaneTest {
    @Test
    fun `Plane fun constructor`() {
        val plane = Plane(Vec3(0.0, 0.0, 1.0), 1.0)
        Assert.assertEquals(2.0, plane.distance, 1.50)
    }

    @Test
    fun `Plane fun clip`() {
        val plane = Plane(Vec3(0.0, 0.0, 1.0), 1.0)
        val point11 = Vec3(0.0, 0.0, 2.0)
        val point12 = Vec3(0.0, 0.0, -2.0)
        val point2 = Vec3(0.0, 0.0, 0.0)
        println("distanceToPoint 11 = ${plane.distanceToPoint(point11)}")
        println("distanceToPoint 12 = ${plane.distanceToPoint(point12)}")
        println("distanceToPoint 2 = ${plane.distanceToPoint(point2)}")
        println("distanceTo      3 = ${point11.distanceTo(point2)}")
        val matrix = Matrix4()
        matrix.setTranslation(0.0 , 0.0 , 1.0)
        plane.transformByMatrix(matrix)
        println("distanceToPoint 4 = ${plane.distanceToPoint(point2)}")
        point2.multiplyByMatrix(matrix)
        println("distanceToPoint 5 = ${point2}")
    }
}